package com.block.merchant.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.common.enums.InfoTypeEnum;
import com.block.merchant.service.IMerchantHandleService;
import com.block.merchant.service.infotype.MerchantApiBHandleService;
import com.block.merchant.service.infotype.MerchantApiHandleService;
import com.block.merchant.service.infotype.MerchantApiSHandleService;
import com.block.merchant.service.infotype.MerchantCRMHandleService;

import java.util.HashMap;
import java.util.Map;

public class InfoTypeFactory {

    private static final Map<String, Class<? extends IMerchantHandleService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(InfoTypeEnum.APIS.getValue(), MerchantApiSHandleService.class);
        serviceMap.put(InfoTypeEnum.APIB.getValue(), MerchantApiBHandleService.class);
        serviceMap.put(InfoTypeEnum.API.getValue(), MerchantApiHandleService.class);
        serviceMap.put(InfoTypeEnum.CRM.getValue(), MerchantCRMHandleService.class);

    }

    public static IMerchantHandleService getService(String pushType){
        if (serviceMap.containsKey(pushType)){
            Class<? extends IMerchantHandleService> aClass = serviceMap.get(pushType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }
}
